package cn.xuchunh.campusbbs.bean;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by XuChunH on 2015/9/12.
 */
public class DataList<T> {

    public int arg1;
    public int arg2;
    public Object target;

    private List<T> list;

    public DataList() {
        this(new ArrayList<T>());
    }

    public DataList(List<T> list) {
        this.list = list;
    }

    public List<T> getList() {
        return list;
    }

    public T get(int location) {
        if (location < 0 || location >= list.size()) {
            return null;
        }
        return list.get(location);
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public void addData(T data) {
        list.add(data);
    }

    public void addDataList(List<T> dataList) {
        list.addAll(dataList);
    }

    public void addDataArray(T[] dataArray) {
        list.addAll(Arrays.asList(dataArray));
    }

    public int size() {
        return list.size();
    }

    public void clear() {
        list.clear();
    }

}
